package com.jvyou.subject.infra.basic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jvyou.subject.infra.basic.entity.SubjectCategory;
import com.jvyou.subject.infra.basic.mapper.SubjectCategoryMapper;
import com.jvyou.subject.infra.basic.service.SubjectCategoryService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;


/**
 * 题目分类(SubjectCategory)表服务实现类
 *
 * @author 橘柚
 * @since 2024-09-24 21:20:57
 */
@Service("subjectCategoryService")
public class SubjectCategoryServiceImpl extends ServiceImpl<SubjectCategoryMapper, SubjectCategory> implements SubjectCategoryService {


    @Override
    public List<SubjectCategory> queryCategory(SubjectCategory subjectCategory) {
        LambdaQueryWrapper<SubjectCategory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(subjectCategory.getId() != null, SubjectCategory::getId, subjectCategory.getId());
        queryWrapper.eq(!StringUtils.isEmpty(subjectCategory.getCategoryType()), SubjectCategory::getCategoryType, subjectCategory.getCategoryType());
        queryWrapper.eq(!StringUtils.isEmpty(subjectCategory.getParentId()), SubjectCategory::getParentId, subjectCategory.getParentId());
        queryWrapper.eq(!StringUtils.isEmpty(subjectCategory.getCategoryName()), SubjectCategory::getCategoryName, subjectCategory.getCategoryName());
        return list(queryWrapper);
    }
}
